<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	class Admin_Controller extends CI_Controller 
	{
	    function __construct()
	    {
	        parent::__construct();
	        /*加载公共资源   */  
	        $this->load->model('Admin_role_model');
	        $this->load->library('form_validation');
	        $this->load->driver('cache');
	        $this->load->library('common');
	        $this->load->helper('common');
	       /*赋值公共类变量  */
	        $this->roleid=0;
	        $top_meun=array();
	        $left_meun=array();
	        self::top_meum();
	        self::left_meum();
	        self::short_menu();
	    }
	    function top_meum()
	    {
	    	//权限判断
	    	if($this->roleid==0)
	    	{
	    		$depth=array('depth'=>0);
	    		$res=$this->Admin_role_model->get_many_by($depth);
	    		foreach($res as $k=>$val)
	    		{
	    			$top_meun[$k]=$val;
	    			$three_priv = $this->Admin_role_model->get_one('','`depth`=1 AND `visiable`=1 AND '," `path` LIKE '%$".$val['id']."$%' ORDER BY `path` LIMIT 1");
	    			$top_meun[$k]['url']=empty($three_priv)?'underfined':$three_priv['url'];
	    		}
	    		$this->cache->file->save('top_meun_'.$this->roleid,$top_meun,'7200');
	    	}else
	    	{
	    		//非管理员
	    	}
	    }
	    function left_meum()
	    {
	    //权限判断
	    	if($this->roleid==0)
	    	{
	    		$depth=array('depth'=>1);
	    		$res=$this->Admin_role_model->get_many_by($depth);
	    		foreach($res as $k=>$val)
	    		{
	    			$left_meun[$k]=$val;
	    			$three_priv = $this->Admin_role_model->get_one('','`depth`=1 AND `visiable`=1 AND '," `path` LIKE '%$".$val['id']."$%' ORDER BY `path` LIMIT 1");
	    			$left_meun[$k]['url']=empty($three_priv)?'underfined':$three_priv['url'];
	    			$left_meun[$k]['method'][]  =empty($three_priv)?'underfined':$three_priv['a'];
	    		}
	    		$this->cache->file->save('left_meun_'.$this->roleid,$left_meun,'7200');
	    	}else
	    	{
	    		//非管理员
	    	}
	    }
	    function short_menu()
	    {
	       $method = $this->uri->segment('3');
	       $show_menu_id=$this->Admin_role_model->getfield_by('a',$method);
	       if($show_menu_id['depth']=='1')
	       $data=array('pid'=>$show_menu_id['id']);
	       else
	       $data=array('pid'=>$show_menu_id['pid']);
	       $show_menu=$this->Admin_role_model->short_menu($data);
	       //echo $this->db->last_query();exit;
	       $this->cache->file->save('short_menu_'.$this->roleid,$show_menu,'7200');
	    }
	}
?>